import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;

/**
 * Author: Daniel Michalski
 * Date: 05.04.13
 */

public class ShowFile {
    public static final String FILE_NAME = "test.txt";

    public static void main(String[] args) {
        int i;

        try ( OutputStream fout =
                      Files.newOutputStream(Paths.get(FILE_NAME)))
        {
            for (int j = 0; j < 26; j++) {
                fout.write((byte)('A' + j));
            }
        } catch (InvalidPathException e) {
            System.out.println("Błąd ścieżki: " + e);
        } catch (IOException e) {
            System.out.println("Błąd wejścia-wyjścia: " + e);
        }


        try (InputStream fin =
                     Files.newInputStream(Paths.get(FILE_NAME))) {
            do {
                i = fin.read();
                if (i != -1) System.out.print((char) i);
            } while (i != -1);
        } catch (InvalidPathException e) {
            System.out.println("Błąd ścieżki: " + e);
        } catch (IOException e) {
            System.out.println("Błąd wejścia-wyjścia: " + e);
        }
    }
}
